//#include<bits/stdc++.h>
#include <iostream>
#include<algorithm>

using namespace std;
int tree[40], back[40], cnt = 1, N;
void dfs(int idx) {
    if (idx > N) return;
    dfs(idx * 2);
    dfs(idx * 2 + 1);
    tree[idx] = back[cnt++];
    cout << idx <<" "<<cnt-1<<" " << tree[idx] << endl;
}

int main() {
    cin >> N;
    for (int i = 1; i <= N; i++) {
        cin >> back[i];
    }
    dfs(1);
    for (int i = 1; i <= N; i++) {
        cout << tree[i];
        if (i != N) cout << " ";
    }
    return 0;
}

